-
Notifications
You must be signed in to change notification settings - Fork 369
Support for Excel templatization #403
base: master
Are you sure you want to change the base?
Support for Excel templatization #403
Conversation
@frisch-raphael thanks for another cool submission. Plugins can support a second database and a modified model for the data. We might be able to move this PR into a plugin and get it landed. On a different note, how difficult would it be to submit some of the Ruby standards compliance code in a different PR? Even better would be a script I could run on my side. |
I can tell you how I did : Open the project with atom : https://atom.io/ Let me know if you have trouble with this, I could always do a quick PR |
Would you considerer adding this PR if I managed to modify the code in a way that wouldn't break the database anymore, or are you set on this being a plugin ? |
Do you plan on finishing this feature? It would be really useful for us. |
I'll try to make a plugin out of this PR when I have some time |
Hi! By any chance, did you find some time to look at it? |
The plugin is pretty much ready. It's just a matter of finding time to make the pull request. |
Hi, any news for this plugin? |
Hi! |
This pull request does the following :
Break the dabatase
Adding this code will break the database, as it changes some key elements and variable names. I suppose it is possible to manually edit your database file (master.db) in ordrer to keep your current database, but I didn't try to do it myself.
Add support for Excel templatization
The fonctionnality in itself
The main functionnality added by this PR, which mean there's now two kind of objects in the database : DocxXslts, and ExcelXslts.
The meta language is the same for both. Every character is supported but the screenshot ones. Metamarkup isn't supported.
The æ metachar is used to repeat the whole row it is on.
A new template file has been added (avaialable at "./templates/Summary Generic.xslx". It's an excel file that provides examples on how to use Serpico's metalanguage for Excel. Feel free to add graphics or template for different scoring types.
How it is implemented
Instead of regexing my way through the meta characters, I used nokogiri and xpathes. This makes the Excel metalanguage more stable, as I feel subtle changes to the Excel XML structure will have less chances to impact the metalanguage fonctionnalities. It also adds possibilities, such as giving the user the exact cell in which there's an error of metachar pairing. I also think it makes the code a bit more understandable, xpath being just a tad bit less tedious to understand than regexes.
I had to modify a LOT of things to make this work with the SerpicoProject master. I hope I didn't break anything in the process.
Moreover, the code was tested for Excel 2016. It would be nice to test this functionnality for other version of Excel.
Centralizes the xslt generation code
All template types (status template, report templates, excel templates, finding template), are now managed by the same route : /report/:id/generate/:template_type.
This was done so that changes in the way xslt is produced doesn't have to be repeated for each generation code part.
EDIT : I can already see that I didn't add this properly. I'll check this when I have time.
homogenizes the code and respect ruby's best practices
The modified files should now respect ruby's best practices from https://github.com/bbatsov/ruby-style-guide
That's the reason the number of line added/removed is so massive.
Rename some functions name
Some functions name were misleading. I Changed them so that they describe what the do most closely
What's the next step ?
When I have time I'd like to add support for powerpoint. This shouldn't be too soon though. I also have quite a few pull request that I didn't have time to make (this one took quite a lot of time).